package cm.mefobe.android.telecomcost.adapter;

import java.util.ArrayList;
import cm.mefobe.android.telecomcost.entities.DailyThreshold;
import cm.mefobe.android.telecomcost.view.AmountView;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class DailyThresholdEditAdapter extends DailyThresholdAdapter {

	public DailyThresholdEditAdapter(Context context, int resource,
			ArrayList<DailyThreshold> objects) {
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
	}

	@Override
	public AmountView getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			Log.i("DailyThresholdAdapter", "getting new Threshold_row_view");
			LayoutInflater vi = (LayoutInflater) _context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(
					cm.mefobe.android.telecomcost.R.layout.threshold_edit_view,
					null);
		} else {
			Log.i("DailyThresholdAdapter",
					"getting existing Threshold_row_view");
		}
		
		AmountView txtAmount = null;
		DailyThreshold threshold = items.get(position);
		if (threshold != null) {
			txtAmount = (AmountView) v
					.findViewById(cm.mefobe.android.telecomcost.R.id.threshold_amount);
			txtAmount.setLabel(threshold.getDay().toString());
			txtAmount.setAmount(threshold.getAmount());
		}
		
		return txtAmount;
	}
}
